package stream;

import java.util.stream.Stream;

/**
 * Stream流注意事项
 */
public class StreamNote {
    public static void main(String[] args) {
        Stream<Integer> stream = Stream.of(1, 2, 3, 4);
//        long count = stream.count();
//        long count1 = stream.count(); // stream流只能操作一次，再次操作会报错
//        System.out.println("count = " + count);

//        Stream<Integer> limit = stream.limit(1);
//        System.out.println("limit == stream = " + (limit == stream)); // stream返回的是新的流

        stream.filter(i -> {
            System.out.println(i);
            return true;
        }); // stream流不调用终结方法，中间操作不会执行
    }
}
